package org.lq.ssm.controller;

import org.lq.ssm.Web.HttpResult;
import org.lq.ssm.dto.MenuDTO;
import org.lq.ssm.dto.mapper.MenuDTOMapper;
import org.lq.ssm.po.UserPO;
import org.lq.ssm.service.MenuService;
import org.lq.ssm.service.UserService;
import org.lq.ssm.vo.MenuVO;
import org.lq.ssm.vo.UserVO;
import org.lq.ssm.vo.mapper.MenuVOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;
import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    MenuService menuService;
    @Autowired
    MenuVOMapper menuVOMapper;


    @GetMapping("getallmenu.do")
    public HttpResult<List<UserVO>> getAllMenus(@RequestParam(name = "level",defaultValue = "1") int level,
                                                @RequestParam(name = "pid" , defaultValue = "0") long pid){
        List<MenuDTO> allMenu = menuService.getAllMenu(pid);
        List<MenuVO> menuVOS = menuVOMapper.menuDTOSToMenuVOS(allMenu);

        return HttpResult.ok(menuVOS,"数据没问题");
    }
}
